﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;

namespace WebApplication1
{
    public partial class AddSite : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            fos_Site newSite = new fos_Site();
            SiteManagement sitemgt = new SiteManagement();
            newSite.SiteName = txtSiteName.Text.Trim();

            newSite.IsDeleted = 0;
            try
            {
                sitemgt.SaveSite(newSite);
                //sitemgt.SendActivationLink(newSite);
                divMessage.Visible = true;
                divMessage.CssClass = "alert alert-success  alert-dismissible";
                lblMessage.Text = "Thank you for adding in new site.";
                listviewSite.DataBind();

            }
            catch (Exception ex)
            {
                divMessage.Visible = true;
                divMessage.CssClass = "alert alert-danger  alert-dismissible";
                lblMessage.Text = ex.Message;
            }
        }

        protected void SiteObject_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
        {
            if (e.Exception == null)
            {
                divMessage.Visible = true;
                divMessage.CssClass = "alert alert-success  alert-dismissible";
                lblMessage.Text = "Site deleted successfully";
            }
            else
            {

                divMessage.Visible = true;
                divMessage.CssClass = "alert alert-danger  alert-dismissible";
                lblMessage.Text = (e.Exception).InnerException.Message.ToString();
                e.ExceptionHandled = true;
            }
        }

        protected void SiteObject_Updated(object sender, ObjectDataSourceStatusEventArgs e)
        {
            if (e.Exception == null)
            {
                divMessage.Visible = true;
                divMessage.CssClass = "alert alert-success  alert-dismissible";
                lblMessage.Text = "Site updated successfully";
            }
            else
            {

                divMessage.Visible = true;
                divMessage.CssClass = "alert alert-danger  alert-dismissible";
                lblMessage.Text = (e.Exception).InnerException.Message.ToString();
                e.ExceptionHandled = true;
            }
        }
    }
}